var app = getApp()
//常量数据配置
var ConstantData = require('../../../../../../common/constant_data.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     

    var that = this;
    wx.showLoading({
      title: '加载中...',
      mask: true
    });
    app.executeRequest(function (header) {
      wx.request({
        url: ConstantData.CONSTATNT_DATA.BASE_URL + '/lease_admin/produce_send/hospitals',
        header: header,
        success: function (res) {
          getApp().hideLoading();
          if (res.data.result === 0) {
            that.setData({
              hospitalList: res.data.data,
              originHospitalList: res.data.data
            })
          }
        }
      })
    });


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  /**
   * 输入医院名称检索
   */
  inputHospital:function(e) {
     
    var inputHospital= e.detail.value;
     
    var hospitals = new Array();
    var originHospitalList = this.data.originHospitalList;
    for (var i = 0; i < originHospitalList.length; i++) {
      if (originHospitalList[i].lbm_name.indexOf(inputHospital) != -1) {
        hospitals.push(originHospitalList[i]);
      }
    }
    if (inputHospital == '') {
      hospitals = this.data.originHospitalList;
    } else if (hospitals.length == 0) {
      this.setData({
        noneDataStat: true
      });
    } else {
      this.setData({
        noneDataStat: false
      });
    }
    this.setData({
      hospitalList: hospitals
    }) 

  },

  /**
   * 选择此医院进行录入
   */
  selHospitalRecord:function(e) {
     
    var lbmid = e.currentTarget.dataset.lbmid;
    var hospitalName = e.currentTarget.dataset.hospitalname;
    wx.navigateTo({
      url: 'record_send_info/record_send_info?lbmid=' + lbmid + "&hospitalName=" + hospitalName,
    });

  }


})